package com.chenyongjing.design.pattern.prototype.shallow;

import java.util.Date;

/**
 * 客户端:克隆
 */
public class Tencent {
    public static void main(String[] args) throws CloneNotSupportedException {
        //原型对象
        Date date = new Date();
        Video v1 = new Video("spring boot",date);
        // v1克隆v2
        Video v2 =(Video) v1.clone();

        System.out.println("v1=>"+v1);
        System.out.println("v1=>"+v1.hashCode());

        // 浅克隆
        date.setTime(2022111111);
        System.out.println("v1=>"+v1);
        System.out.println("v1=>"+v1.hashCode());

        System.out.println("v2=>"+v2);
        System.out.println("v2=>"+v2.hashCode());

        v2.setName("clone spring boot");
        System.out.println("v2=>"+v2);
        System.out.println("v2=>"+v2.hashCode());

        //深克隆：序列化，反序列化，改造克隆方法

    }
}
